'''
计算s与pi的误差
'''
import math
n = int(input("请输入一个介于5到20之间的正整数n："))
s1 = 0
s2 = 0
if (n >= 5 and n <= 20):
    for num in range(1, n + 1):
        s1 += (-1)**(num - 1) * (1 / (2 * num - 1)) * (1 / 5)**(2 * num - 1)
        s2 += (-1)**(num - 1) * (1 / (2 * num - 1)) * (1 / 239)**(2 * num - 1)
        num += 1
    s = 16 * s1 - 4 * s2
    print(s)
    pi = math.pi
    print(pi)
    wucha = abs(pi - s)
    print("s与pi误差为：{}".format(wucha))
